<?php
namespace Buu\Modules\HaohaoceManager\Lib;

class Git{
	static public function listBranch($git_path){
		$cmd = 'cd '.$git_path.' ;git branch -a';
		$rs = self::_run_cmd($cmd);

		$rs = explode("\n" , $rs);

		unset($rs[0]);
		unset($rs[0]);

		// foreach ($rs as $key =>$branch) {
		// 	$rs[$key] = substr($branch , 9);
		// }
		return $rs;
	}


	static private function _run_cmd($cmd){
		$fp = popen($cmd , 'r');
		while ($str = fread($fp , 4096)) {
			$rs.=$str;
		};
		return $rs;
	}
}